package com.humi.partner.common.dict;

public enum PartnerBaseStatus {
    NOTSUBMITTED(0, "审核中"),

    INPROGRESS(1, "审核通过"),

    FINISHED(2, "审核驳回重新修改"),

    SELECTED(3, "审核驳回不能再提交"),;

    private Integer code;

    private String name;
    private PartnerBaseStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据KEY转换为对应枚举类别.
     *
     * @param code
     * @return PurchaseType
     */
    public static PartnerBaseStatus format(Integer code) {
        if (null == code) {
            return null;
        }
        for (PartnerBaseStatus item : PartnerBaseStatus.values()) {
            if (code.equals(item.getCode())) {
                return item;
            }
        }
        return null;
    }

    /**
     *
     * <pre>
     * 获取进行中的状态
     * </pre>
     *
     * @return like this"(a,b)"
     */
    public static String getInProgressCode() {
//		return "'('" + new ArrayList<>(Arrays.asList(RecruitStatus.values())).stream()
//			.filter(node -> node.getCode() == 0 || node.getCode() == 1|| node.getCode() == 3|| node.getCode() == 4)
//			.map(node -> node.getCode().toString()).collect(Collectors.joining(",")) + "')'";
        StringBuffer statusbBuffer = new StringBuffer();
        statusbBuffer.append('(');
        int length = PartnerBaseStatus.values().length;
        for (int i = 0; i < length; i++) {
            int code = PartnerBaseStatus.values()[i].getCode();
            if (code == 0 || code == 1|| code == 3|| code == 4) {
                statusbBuffer.append(code);
                statusbBuffer.append(',');
            }
        }
        statusbBuffer.setLength(statusbBuffer.length()-1);
        statusbBuffer.append(')');
        return statusbBuffer.toString();
    }

    public Integer getCode() {
        return code;
    }


    public String getName() {
        return name;
    }
}
